#include "../userprog/syscall.h"

void main(){

char * execName;
int nameLen;

int NUM_TICKET_TAKERS;
int latestIndexLock;
int latestIndexCondition;
int latestIndex;

latestIndex = CreateMV(1, "latestIndex", 11);
NUM_TICKET_TAKERS = CreateMV(1, "NUM_TICKET_TAKERS", 17);
latestIndexLock = CreateLock("latestIndexLock",15);
latestIndexCondition = CreateCondition("latestIndexCondition",20);

NUM_TICKET_TAKERS = CreateMV(1, "NUM_TICKET_TAKERS", 17);

for(SetMV(latestIndex,0,0); GetMV(latestIndex,0) < GetMV(NUM_TICKET_TAKERS,0); SetMV(latestIndex,0,GetMV(latestIndex,0) + 1))
{


	AcquireLock(latestIndexLock);
	execName = "../test/tickettaker";
	nameLen = 19;
	Exec(execName, nameLen);
	WaitCondition(latestIndexCondition, latestIndexLock);
	ReleaseLock(latestIndexLock);
}
}